package com.example.grpc.consume.web.resources;

import com.example.grpc.consume.service.HelloWorldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liyuncong
 * @version 1.0
 * @file HelloResource
 * @brief HelloResource
 * @details HelloResource
 * @date 2022-11-09
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                        NAME               DESCRIPTION
 * 2022-11-09                  liyuncong          Created
 */
@RestController
@RequestMapping(path = "/api/v1")
public class HelloResource {

    @Autowired
    private HelloWorldService helloWorldService;

    @GetMapping("/say")
    public ResponseEntity<String> sayHello(
        @RequestParam(value = "name", required = false) String name
    ) {
        final String hello = helloWorldService.sayHello(name);
        return ResponseEntity.ok(hello);
    }
}
